*This file creates industry robustness table D.7

use "$path/industry_data.dta", clear

*Import industry skill. See paper for details.
joinby digt2 using "$path/ind_edu.dta", unmatched(master)

gen ln_repa_tot_post=ln_repa_tot*post
gen ln_repa_tot_post_h=ln_repa_tot*post*high_edu
gen ln_repa_tot_post_l=ln_repa_tot*post*(high_edu==0)
gen high_post=post*high_edu

foreach var in ln_value_prod lnlabor_all ln_valueadded {
reghdfe `var' ln_repa_tot_post_h ln_repa_tot_post_l   high_post  , absorb(year isic $linearcontrols) vce(cluster isic) resid
estadd local ii "155"
estimates store `var'1 
estadd local base "\checkmark"
estadd local yfe "\checkmark"
estadd local established "Yes"

reghdfe `var' ln_repa_tot_post_h ln_repa_tot_post_l   high_post if timberpaper==0 , absorb(year isic $linearcontrols) vce(cluster isic) resid
estadd local ii "135"
estimates store `var'3
estadd local base "\checkmark"
estadd local yfe "\checkmark"
estadd local established "No"
}

preserve
keep if year==1943
egen  hs_std=std(repa_sharel*high_edu)
egen  ls_std=std(repa_sharel*(high_edu==0))
tempfile shocks
keep isic ls_std hs_std
save `shocks'
restore

preserve
keep if year==1943&timberpaper==0
egen  hs_std2=std(repa_sharel*high_edu)
egen  ls_std2=std(repa_sharel*(high_edu==0))
tempfile shocks2
keep isic ls_std2 hs_std2
save `shocks2'
restore

drop _merge
joinby isic using `shocks', unmatched(master)

drop _merge
joinby isic using `shocks2', unmatched(master)

gen ls_std_post=post*ls_std
gen hs_std_post=post*hs_std

gen ls_std_post2=post*ls_std2
gen hs_std_post2=post*hs_std2

foreach var in ln_value_prod lnlabor_all ln_valueadded {
reghdfe `var'   hs_std_post ls_std_post high_post , absorb(year isic $linearcontrols) vce(cluster isic) resid
estadd local ii "155"
estimates store `var'2
estadd local base "\checkmark"
estadd local yfe "\checkmark"
estadd local established "Yes"

preserve

replace hs_std_post=hs_std_post2
replace ls_std_post=ls_std_post2

reghdfe `var'   hs_std_post ls_std_post high_post if timberpaper==0, absorb(year isic $linearcontrols) vce(cluster isic) resid
estadd local ii "135"
estimates store `var'4
estadd local base "\checkmark"
estadd local yfe "\checkmark"
estadd local established "No"
restore 
}

label var hs_std_post "High Skill x Reparations Share x Post"
label var ls_std_post "Low Skill x Reparations Share x Post"
label var ln_repa_tot_post_h "High Skill x ln(Reparations) x Post"
label var ln_repa_tot_post_l "Low Skillx ln(Reparations) x Post"
label var high_post "High Skill x Post"

esttab   ln_value_prod2 ln_value_prod4  ln_value_prod1 ln_value_prod3   lnlabor_all2 lnlabor_all4  lnlabor_all1  lnlabor_all3     ln_valueadded2 ln_valueadded4 ln_valueadded1 ln_valueadded3   using   "$tables/Heterogeneity_control.tex",  ///
mgroups("ln Value of Production" "ln Labor Force"  "ln Value Added" ,   pattern(1 0 0 0  1 0 0 0 1 0 0 0 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
	replace  keep( hs_std_post ls_std_post ln_repa_tot_post_h ln_repa_tot_post_l   high_post)  order( hs_std_post ls_std_post ln_repa_tot_post_h ln_repa_tot_post_l   high_post)  nonotes ///
	 b(%9.3f) se(%9.3f) stats(N ii base established, fmt(0 3) layout(@ @ @) ///
		labels("N" "Industries" "Elastic net controls"   "Established" ///
			)) ///
label star(* .1 ** .05 *** .01) nodepvars nomtitle 	
		
